﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entities;
using Utility;
using BUS;

public partial class Administrator_sanpham_Update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
            {
                    load_data();
            }
    }

    private void load_data()
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        Tbl_SanPham_Entities sp = Tbl_SanPham_BUS.GetByID(id);
        txt_MaSP.Text = sp.MaSP;
        ddl_tinhtrang.SelectedValue = sp.TinhTrang;
        
        HiddenField1.Value = sp.STT.ToString();
    }

       

    protected void btn_Up_Click(object sender, EventArgs e)
    {
        Tbl_SanPham_Entities sp = Tbl_SanPham_BUS.GetByID(int.Parse(HiddenField1.Value));
        sp.MaSP = txt_MaSP.Text;
        sp.TinhTrang = ddl_tinhtrang.SelectedItem.Text;
        sp.STT = int.Parse(HiddenField1.Value);
        //Tbl_SanPham_BUS.Update1(sp);

        Literal1.Text = "Cập nhật thành công";
        btn_Up.Visible = false;
        HyperLink1.Text = "Về lại trang Danh Sách Loại Sản Phẩm";
        HyperLink1.Visible = true;
        HyperLink1.NavigateUrl = "~/Administrator/sanpham.aspx";
    }
   
}
